<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js/jquery-3.6.0.min.js"></script>
    <script>
        $(function () {
            $("#btn1").click(function () {
                $.get("/employees/1",function (data) {
                    console.log(data);
                })
            })

            $("#btn2").click(function () {
                $.get("/employees",function (data) {
                    console.log(data);
                })
            })

            $("#btn3").click(function () {
                $.post("/employees",{name:"小文",age:21},function (data) {
                    console.log(data);
                })
            })

            $("#btn4").click(function () {
                $.ajax({
                    url:"/employees",
                    type:"DELETE",
                    data:{id:1},
                    success:function (data) {
                        console.log(data);
                    }
                })
            })

            $("#btn5").click(function () {
                $.ajax({
                    url:"/employees",
                    type:"PUT",
                    data:{name:"小王",age:32},
                    success:function (data) {
                        console.log(data);
                    }
                })
            })
        })

       function login() {
            var userName = $("#userName").val();
            var password = $("#password").val();
            $.post("/login",{userName:userName,password:password},function (data) {
                alert(data.msg);
                console.log(data.msg);
            })

       }

        function logout() {
            $.post("/logout",function (data) {
                alert(data.msg);
                console.log(data.msg);
            })

        }
    </script>

</head>
<body>
<button id="btn1">查单个</button>
<button id="btn2">查多个</button>
<button id="btn3">添加</button>
<button id="btn4">删除</button>
<button id="btn5">更新</button></br></br>


账号:<input type="text" id="userName" name="userName" placeholder="请输入账号"></br>
密码:<input type="text" id="password" name="password" placeholder="请输入密码"> </br>
<input type="button" onclick="login()" value="登录">
<input type="button" onclick="logout()" value="注销">


</body>
</html>